package logic

import (
	"context"

	"go-zero-mall/app/product/cmd/rpc/internal/svc"
	"go-zero-mall/app/product/cmd/rpc/pb"
	"go-zero-mall/app/product/model"

	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type PmsMemberPriceInfoInsertLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewPmsMemberPriceInfoInsertLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PmsMemberPriceInfoInsertLogic {
	return &PmsMemberPriceInfoInsertLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *PmsMemberPriceInfoInsertLogic) PmsMemberPriceInfoInsert(in *pb.PmsMemberPriceInfoInsertReq) (*pb.PmsMemberPriceInfoInsertResp, error) {
	var d model.PmsMemberPrice
	copier.Copy(&d, in)
	_, err := l.svcCtx.PmsMemberPriceModel.Insert(l.ctx, &d)
	if err != nil {
		return nil, err
	}
	return &pb.PmsMemberPriceInfoInsertResp{}, nil
}
